<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

$_LangPath = "number51";	//語言檔參數，務必放在最前面
include_once(__Member_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_member.php");

$fp = @file(__Membertemplate_Path."/number51_".$_data["stype"].".html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);
$fp = str_replace("{SelfFile}", $_SERVER["PHP_SELF"], $fp);
$fp = str_replace("{ShowAccount}", $_SESSION["Member_Info"] -> Account, $fp);
$fp = str_replace("{UserID}", $_SESSION["Member_Info"] -> ID, $fp);
$fp = str_replace("{sid}", $_data["sid"], $fp);

$intLID = (int)$_data["LottoID"];
if(empty($intLID))$intLID = 2;

include_once(__Common_Path."/SysParam.inc.php");
include_once(__Common_Path."/limit/LottoLimit_".$intLID.".inc.php");
include_once(__Common_Path."/betparam/BetParam_".$intLID.".inc.php");
include_once(__Root_Path."/tmp/credit-".$_SESSION["Member_Info"] -> ID.".php");
@include_once(__Common_Path."/todaygame/Gamble".$intLID.".inc.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Common_Path."/ExchangeRate.inc.php");
include_once(__Modules_Path."/ChangeTime.lib.php");

$MemExchangeRate = (empty($_ECRate[$_SESSION["Member_Info"] -> ERID]["Rate"]))?1:$_ECRate[$_SESSION["Member_Info"] -> ERID]["Rate"];
//取出此期賽程
if(is_array($_arrGamble))list($intGID, $arrGamble) = each($_arrGamble);

$intTmp = $_SESSION["Member_Info"] -> CreditLine - $_arrMemStake["_SUM"];
$fp = str_replace("{CreditValue}", $intTmp, $fp);

$fp = str_replace("{LottoID}", $intLID, $fp);

$strEndTime = "";
$strGameTime = "";
if (!is_array($arrGamble)) {
	$strEndTime = "2100-01-01 01:01:01";
	$strGameTime = "00:00";
} else {
	$strEndTime = TimeForm($arrGamble[GameDate], $arrGamble[EndGameTime], "Y-m-d H:i:s", "UToC");
	$strGameTime = TimeForm($arrGamble[GameDate], $arrGamble[GameTime], "H:i", "UToC");
}
$fp = str_replace("{ShowEndGameTime}", $strEndTime, $fp);
$fp = str_replace("{ShowGameTime}", $strGameTime, $fp);

if($_data["stype"] == "c"){
	$arrBT = array(51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 84, 85, 86);
	$fp = str_replace("{GambleID}", $intGID, $fp);
	foreach($arrBT as $intBT){
		$fp = str_replace("{MaxEventLimitValue$intBT}", $_SESSION["Member_Info"] -> arrEventLimit[$intLID][$intBT], $fp);
		$fp = str_replace("{MaxBetLimitValue$intBT}", $_SESSION["Member_Info"] -> arrBetLimit[$intLID][$intBT], $fp);
		$fp = str_replace("{LottoMaxEventLimitValue$intBT}", floor($_arrLottoLimit[$intBT][0] / $MemExchangeRate), $fp);
		$fp = str_replace("{LottoMaxBetLimitValue$intBT}", floor($_arrLottoLimit[$intBT][1] / $MemExchangeRate), $fp);

		$intMinStakeValue = 9999999;
		$intChkMaxPayOff = 9999999;
		foreach($_arrBetParam[$intBT] as $intAN => $arrBP){
			if(floor($arrBP["MinStake"] / $MemExchangeRate) < $intMinStakeValue)$intMinStakeValue = floor($arrBP["MinStake"] / $MemExchangeRate);
			if(floor($arrBP["MaxPayOff"] / $MemExchangeRate) < $intChkMaxPayOff)$intChkMaxPayOff = floor($arrBP["MaxPayOff"] / $MemExchangeRate);
		}
		$fp = str_replace("{MinStake$intBT}", $intMinStakeValue, $fp);
		$fp = str_replace("{MaxPayOff$intBT}", $intChkMaxPayOff, $fp);
	}
}

$fp = str_replace("{MaxEventLimitValue}", $_SESSION["Member_Info"] -> arrEventLimit[$intLID][$intBID], $fp);
$fp = str_replace("{MaxBetLimitValue}", $_SESSION["Member_Info"] -> arrBetLimit[$intLID][$intBID], $fp);
$fp = str_replace("{LottoMaxEventLimitValue}", floor($_arrLottoLimit[$intBID][0] / $MemExchangeRate), $fp);
$fp = str_replace("{LottoMaxBetLimitValue}", floor($_arrLottoLimit[$intBID][1] / $MemExchangeRate), $fp);
$fp = str_replace("{MinStakeValue}", floor($_arrBetParam[$intBID]["MinStake"] / $MemExchangeRate), $fp); //最低下注金額
$fp = str_replace("{MaxPayOff}", $_arrBetParam[$intBID]["MaxPayOff"], $fp);	//最高派彩

$fp = str_replace("{time}", "04", $fp);

while(list($k, $v) = each($_strNumber51)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//輸出
WebOutputHTML($fp, 1);
?>